{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "26f95b3f",
   "metadata": {},
   "source": [
    "多因子04单因子测试-20231024-单因子测试基本逻辑<br>\n",
    "https://www.wolai.com/stupidccl/qbAG9aJ2V7cAoxPbpogoZT <br>\n",
    "https://www.bilibili.com/video/BV1SG411R7QD"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5f36a649",
   "metadata": {},
   "source": [
    "## 单因子测试\n",
    "\n",
    "我们将单因子比喻为“食材”，在烹饪的过程中，为了制作一份优质的料理，大厨们会对食材精挑细选，<br>\n",
    "从新鲜度、产地、色泽等多方面来评价食材，从而最终确定是否在料理中使用这一食材。<br>\n",
    "同样地，在多因子体系下，我们从自己的投资理念中提取出单因子，并对其进行量化，<br>\n",
    "紧接着就需要对因子进行完整、全面的“体检”，即单因子测试。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c4c69b4e",
   "metadata": {},
   "source": [
    "### 单因子测试基本逻辑"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a7a6e4f3",
   "metadata": {},
   "source": [
    "### IC RankIC"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "97b21f0d",
   "metadata": {},
   "source": [
    "### IC\n",
    "\n",
    "挖掘和计算因子的最终目的是希望因子能够准确预测涨跌"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "76099511",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>因子值</th>\n",
       "      <th>T+5日收益率1</th>\n",
       "      <th>T+5日收益率2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>3</td>\n",
       "      <td>8.0</td>\n",
       "      <td>0.1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>5.7</td>\n",
       "      <td>-5.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0</td>\n",
       "      <td>3.6</td>\n",
       "      <td>10.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>-1</td>\n",
       "      <td>-3.3</td>\n",
       "      <td>-9.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>-2</td>\n",
       "      <td>-6.5</td>\n",
       "      <td>0.1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   因子值  T+5日收益率1  T+5日收益率2\n",
       "0    3       8.0       0.1\n",
       "1    2       5.7      -5.7\n",
       "2    0       3.6      10.0\n",
       "3   -1      -3.3      -9.0\n",
       "4   -2      -6.5       0.1"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "\n",
    "df = pd.DataFrame({\n",
    "    '因子值': [3, 2, 0, -1, -2],\n",
    "    'T+5日收益率1': [8, 5.7, 3.6, -3.3, -6.5],\n",
    "    'T+5日收益率2': [0.1, -5.7, 10, -9, 0.1],\n",
    "})\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "5db069a1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>因子值</th>\n",
       "      <th>T+5日收益率1</th>\n",
       "      <th>T+5日收益率2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>因子值</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.954526</td>\n",
       "      <td>-0.008330</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>T+5日收益率1</th>\n",
       "      <td>0.954526</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.225281</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>T+5日收益率2</th>\n",
       "      <td>-0.008330</td>\n",
       "      <td>0.225281</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               因子值  T+5日收益率1  T+5日收益率2\n",
       "因子值       1.000000  0.954526 -0.008330\n",
       "T+5日收益率1  0.954526  1.000000  0.225281\n",
       "T+5日收益率2 -0.008330  0.225281  1.000000"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.corr()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9613dad4",
   "metadata": {},
   "source": [
    "收益率1和因子相关系数0.95，高度正相关——<font color=\"red\">因子越高，那么5天后股票涨的越好</font><br>\n",
    "收益率2和因子相关系数-0.0083，几乎不相关——<font color=\"green\">因子和股票未来5天的涨跌，没什么线性关系</font>"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1545e4e9",
   "metadata": {},
   "source": [
    "<font color=\"#FF0000\">这段文本是红色字体。</font>  \n",
    "<font color=\"green\">\n",
    "<font color=\"red\">"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1b17e966",
   "metadata": {},
   "source": [
    "#### 信息系数(Information Coefficient，IC)\n",
    "我们用相关性衡量因子对收益率的预测能力，在因子测试中，这种相关性计算的结果，<br>\n",
    "称为信息系数(Information Coefficient，IC)，代表的是因子对未来股票收益率的预测作用"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9288a097",
   "metadata": {},
   "source": [
    "## RankIC"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "61eaff34",
   "metadata": {},
   "source": [
    "异常值怎么办？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "21515c0f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>因子值</th>\n",
       "      <th>T+5日收益率1</th>\n",
       "      <th>T+5日收益率1_异常</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>3</td>\n",
       "      <td>8.0</td>\n",
       "      <td>8.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>5.7</td>\n",
       "      <td>5.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0</td>\n",
       "      <td>3.6</td>\n",
       "      <td>3.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>-1</td>\n",
       "      <td>-3.3</td>\n",
       "      <td>-3.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>-2</td>\n",
       "      <td>-6.5</td>\n",
       "      <td>-8.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>-3</td>\n",
       "      <td>-8.0</td>\n",
       "      <td>50.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   因子值  T+5日收益率1  T+5日收益率1_异常\n",
       "0    3       8.0          8.0\n",
       "1    2       5.7          5.7\n",
       "2    0       3.6          3.6\n",
       "3   -1      -3.3         -3.3\n",
       "4   -2      -6.5         -8.0\n",
       "5   -3      -8.0         50.0"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df1 = pd.DataFrame({\n",
    "    '因子值': [3, 2, 0, -1, -2, -3],\n",
    "    'T+5日收益率1': [8, 5.7, 3.6, -3.3, -6.5, -8],\n",
    "    'T+5日收益率1_异常': [8, 5.7, 3.6, -3.3, -8, 50],\n",
    "})\n",
    "\n",
    "df1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "bdaea33b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>因子值</th>\n",
       "      <th>T+5日收益率1</th>\n",
       "      <th>T+5日收益率1_异常</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>因子值</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.969839</td>\n",
       "      <td>-0.356942</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>T+5日收益率1</th>\n",
       "      <td>0.969839</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>-0.318652</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>T+5日收益率1_异常</th>\n",
       "      <td>-0.356942</td>\n",
       "      <td>-0.318652</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                  因子值  T+5日收益率1  T+5日收益率1_异常\n",
       "因子值          1.000000  0.969839    -0.356942\n",
       "T+5日收益率1     0.969839  1.000000    -0.318652\n",
       "T+5日收益率1_异常 -0.356942 -0.318652     1.000000"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df1.corr()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cdda9109",
   "metadata": {},
   "source": [
    "结果显示，异常收益率和因子呈现负相关关系，但是，大部分情况下，其收益率和因子是同向变化的，直接用相关系数计算的结果，显然不太合理"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9eb92a51",
   "metadata": {},
   "source": [
    "#### 我们先将数据转换为<font color=\"red\">排名</font>，再进行相关系数计算\n",
    "\n",
    "rank() 函数用于对数据框中的某一列进行降序排名。这里的 ascending=False 表示排名是降序的，即从大到小。如果设置为 ascending=True，则表示升序排名，即从小到大。\n",
    "\n",
    "corr() 函数用于计算数据框中两列之间的相关性。这里的 method='spearman' 表示使用 Spearman 方法计算相关性。Spearman 方法是一种非参数检验方法，用于检验两组数据之间是否存在单调关系。如果 method 参数设置为 'pearson'，则表示使用 Pearson 相关系数计算相关性。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "e6b421d8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>因子值</th>\n",
       "      <th>T+5日收益率1</th>\n",
       "      <th>T+5日收益率1_异常</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>4.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>5.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>6.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>6.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   因子值  T+5日收益率1  T+5日收益率1_异常\n",
       "0  1.0       1.0          2.0\n",
       "1  2.0       2.0          3.0\n",
       "2  3.0       3.0          4.0\n",
       "3  4.0       4.0          5.0\n",
       "4  5.0       5.0          6.0\n",
       "5  6.0       6.0          1.0"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rankDf = df1.rank(ascending=False)\n",
    "rankDf"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "de6658ba",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>因子值</th>\n",
       "      <th>T+5日收益率1</th>\n",
       "      <th>T+5日收益率1_异常</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>因子值</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.142857</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>T+5日收益率1</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.142857</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>T+5日收益率1_异常</th>\n",
       "      <td>0.142857</td>\n",
       "      <td>0.142857</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                  因子值  T+5日收益率1  T+5日收益率1_异常\n",
       "因子值          1.000000  1.000000     0.142857\n",
       "T+5日收益率1     1.000000  1.000000     0.142857\n",
       "T+5日收益率1_异常  0.142857  0.142857     1.000000"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rankDf.corr()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "1055c954",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>因子值</th>\n",
       "      <th>T+5日收益率1</th>\n",
       "      <th>T+5日收益率1_异常</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>因子值</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.142857</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>T+5日收益率1</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.142857</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>T+5日收益率1_异常</th>\n",
       "      <td>0.142857</td>\n",
       "      <td>0.142857</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                  因子值  T+5日收益率1  T+5日收益率1_异常\n",
       "因子值          1.000000  1.000000     0.142857\n",
       "T+5日收益率1     1.000000  1.000000     0.142857\n",
       "T+5日收益率1_异常  0.142857  0.142857     1.000000"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df1.corr(method='spearman')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b95e2ad8",
   "metadata": {},
   "source": [
    "可以看到，spearman相关系数的特点是**只考虑两个向量中排序是否一致**，这样就能很好地避免异常值的影响。<br>\n",
    "在本例中，最后一条记录的收益率异常造成了pearson相关系数和spearman相关系数的计算结果出现了方向性的不同。<br>\n",
    "pearson相关系数约为-0.35，而spearman相关系数约为0.14，得出的结论也截然相反：spearman显示因子正相关，pearson显示因子负相关"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6aaeed43",
   "metadata": {},
   "source": [
    "rankDf = df1.rank(ascending=False)<br>\n",
    "rankDf.corr()<br>\n",
    "df1.corr(method='spearman')\n",
    "\n",
    "第一行代码：<br>\n",
    "rankDf = df1.rank(ascending=False)<br>\n",
    "这句代码计算了 df1 中所有列的降序排名，并将结果存储在一个新的数据框 rankDf 中。<br>\n",
    "第二行代码：<br>\n",
    "rankDf.corr()<br>\n",
    "这句代码计算了 rankDf 中所有列之间的相关性。<br>\n",
    "第三行代码：<br>\n",
    "df1.corr(method='spearman')<br>\n",
    "这句代码计算了 df1 中所有列之间的 Spearman 相关性。<br>\n",
    "在这种情况下，由于我们在第一行代码中计算了排名，并且在第二行代码中计算了相关性，<br>\n",
    "这时我们实际上已经将原始数据转换为了排名数据。<br>\n",
    "因此，第二行代码和第三行代码计算的相关性，实际上都是基于排名数据进行的，所以它们的结果是相同的。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3dc7b85d",
   "metadata": {},
   "source": [
    "### RankIC（秩IC）\n",
    "从spearman相关系数的计算原理可知，这一方法只考虑排序结果，因此用spearman计算出来的IC也叫作“RankIC”，或者叫“秩IC”"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c0f7d406",
   "metadata": {},
   "source": [
    "## 分组测试\n",
    "直接使用单个因子的因子值构建简单的股票组合进行回测，这就是“单因子分组测试”。<br>\n",
    "分组很简单，通常在时间截面上根据因子值的大小对股票进行分组。<br>\n",
    "例如，我们把2019年5月27日这一天市场上的股票先按照被测试因子值从小到大排序，<br>\n",
    "然后将其按照数值大小分成一定的股票组别。<br>\n",
    "我们可以规定每组的股票数量相同，也可以指定特定因子值区间为一组。<br>\n",
    "分组测试就是在每一次调仓的时候将之前的分组组合调整为新的分组组合。<br>\n",
    "还可以使用多空组合：做多表现最好的因子组合同时做空因子表现最差的组合"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b8bd482a",
   "metadata": {},
   "source": [
    "## 稳定性检验\n",
    "如果某一个因子的预测效果很好，但是因子值的变动较大，<br>\n",
    "对股票的打分不断有较大幅度的变化，那么就会造成每次调仓的时候换手率过高。<br>\n",
    "过高的换手率会带来更高的交易成本和流动性风险。<br>\n",
    "因此，我们也会检验分组组合的换手率情况以及因子的自相关性"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f2cc36f8",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d47309f1",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a0b0328e",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b5fa7dd3",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4aa06718",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
